﻿using System;
using System.Security.Cryptography.X509Certificates;

namespace _05_Console
{
    internal class Program
    {
        static void Main(string[] args)
        {
            #region 装箱拆箱
            //object a = 3;
            //int aa = Convert.ToInt32(a);
            //Console.WriteLine(a);
            //Console.WriteLine(aa);
            #endregion
            //int a1 = 4, b1 = 6;
            ////Console.WriteLine(FindMax(a1, b1));
            //int min = FindMin(ref a1, ref b1);
            //Console.WriteLine($"{a1},{b1}");
            //int a1 = 4, a2 = 5;
            //Bigger(ref a1,ref a2);
            //Console.WriteLine("a1:{0},a2:{1}", a1, a2);
            int a1 = 1;
            int a2 = 9;
            int a3 = 9;
            double avg = 0;
            int max = FindMaxAndAvg(a1, a2, a3, out avg);
            Console.WriteLine("max:{0},min:{1}",max,avg);
        }

        #region 方法
        /// <summary>
        /// 返回两个数的最大值
        /// </summary>
        /// <param name="num1">数字1</param>
        /// <param name="num2">数字2</param>
        /// <returns>返回两个数的最大值</returns>
        //static public int FindMax(int num1, int num2)
        //{
        //    return num1 > num2 ? num1 : num2;
        //}
        //static public int FindMin(ref int num1, ref int num2)
        //{
        //    num1 *= 5; num2 *= 5;
        //    return num1 < num2 ? num1 : num2;
        //}
        #endregion

        #region out,ref
        // out：用于查看形参
        //static void Bigger(ref int num1,ref int num2)
        //{
        //    num1 *= 4;
        //    num2 *= 4;
        //    Console.WriteLine("num1:{0},num2:{1}", num1, num2);
        //}

        static int FindMaxAndAvg(int num1,int num2,int num3,out double avg)
        {
            avg = (num1+num2+num3)/3.0;
            return (num1 > num2 ? num1 : num2) > num3 ? (num1 > num2 ? num1 : num2) : num3;
        }


        #endregion
    }
}
